home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / tclMotif-1.4 / programs / prog44 < prev    next >
Encoding:
Text File  |  1995-06-29  |  992 b   |  51 lines

  1. # testing if we can send events to a widget
  2. # and get a result back out of it
  3.  
  4. proc activateCB {} {
  5.     return "...activated"
  6. }
  7.  
  8. proc disarmCB {} {
  9.     return "...disarmed"
  10. }
  11.  
  12. proc armCB {} {
  13.     return "...armed"
  14. }
  15.  
  16. xtAppInitialize -class Btn
  17.  
  18. xmPushButton .btn managed -labelString "Hello world"
  19.  
  20. .btn activateCallback activateCB
  21. .btn armCallback armCB
  22. .btn disarmCallback disarmCB
  23.  
  24. . realizeWidget
  25.  
  26. puts stdout "calling arm"
  27. puts [.btn callActionProc Arm()]
  28.  
  29. # activate assumes it comes from a ButtonPress.
  30. # coords within its boundaries mean ButtonRelease
  31. # occurs within the widget, so activate callback occurs.
  32. # outside this, no callback is invoked
  33.  
  34. # this one is inside boundary
  35. puts stdout "calling activate"
  36. puts stdout [.btn callActionProc Activate() \
  37.     -type ButtonPress \
  38.     -x 0 -y 0]
  39.  
  40. puts stdout "calling disarm"
  41. puts [.btn callActionProc Disarm()]
  42.  
  43. puts stdout "calling armAndActivate"
  44. puts [.btn callActionProc ArmAndActivate()]
  45.  
  46. . mainLoop
  47.  
  48. . realizeWidget
  49.  
  50. . mainLoop
  51.